package xiaomogu.task_engine.admin.core.scheduler;

import xiaomogu.task_engine.admin.core.util.I18nUtil;


public enum ScheduleType {

    NONE(I18nUtil.getString("schedule_type_none")),

    /**
     * schedule by cron
     */
    CRON(I18nUtil.getString("schedule_type_cron")),

    /**
     * schedule by fixed rate (in seconds)
     */
    FIX_RATE(I18nUtil.getString("schedule_type_fix_rate"));

    private String code;

    ScheduleType(String code) {
        this.code = code;
    }

    public static ScheduleType match(String code, ScheduleType defaultItem) {
        for (ScheduleType scheduleType : ScheduleType.values()) {
            if (scheduleType.name().equals(code)) {
                return scheduleType;
            }
        }
        return defaultItem;
    }

    public String getCode() {
        return code;
    }

}
